package com.tdk.bts.view.manager;

import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import com.tdk.bts.entity.Theater;

public class ManagerIndexView {
	
	private JFrame jf;
	
	private JTabbedPane mainPanel;
	
	private FilmManagerView filmManagerView;
	
	private TheaterManagerView theaterManagerView;
	
	private BookInfoManagerView bookInfoManagerView;
	
	private GetTicketView getTicketView;
	
	public void show()
	{
		init();
		setStyle();
		registHandler();
		jf.setVisible(true);
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	private void registHandler() {
		mainPanel.addChangeListener(new ChangeListener() {
			
			@Override
			public void stateChanged(ChangeEvent e) {
				
				BaseTabbedPanel btp = (BaseTabbedPanel) mainPanel.getSelectedComponent();
				btp.bindData(1);
				
			}
		});
	}

	private void init() {
		jf = new JFrame();
		
		mainPanel = new JTabbedPane(); 
		
		filmManagerView = new FilmManagerView(jf);
		
		theaterManagerView = new TheaterManagerView();
		
		bookInfoManagerView = new BookInfoManagerView();
		
		getTicketView = new GetTicketView();
	}

	private void setStyle() {
		jf.setSize(800, 600);
		jf.setLocationRelativeTo(null);
		
		mainPanel.add("影片管理", filmManagerView);
		mainPanel.add("放映厅管理", theaterManagerView);
		mainPanel.add("预定管理", bookInfoManagerView);
		mainPanel.add("取票", getTicketView);
		
		jf.add(mainPanel);
	}

	
	public static void main(String[] args) {
		new ManagerIndexView().show();
	}
	
}
